Hệ thống quản lý ISP trong PHP

1 <?php
2     
// Start from getting the hader which contains some settings we need
3     require_once
'includes/header.php';
4     
// Redirect visitor to the login page if he is trying to access
5     
// this page without being logged in
6     
if (!isset($_SESSION['admin_session']) )
7     {
8         $commons->redirectTo(SITE_PATH.
'login.php');
9     }
10 ?>
11
12     <div
class="dashboard">
13
14     <div
class="col-md-12 col-sm-12" id="product_table">
15     <div
class="panel panel-default">
16         <div
class="panel-heading">
17         <h4>Products</h4>
18         </div>
19         <div
class="panel-body">
20             <div
class="col-md-6">
21                 <button type=
"button" name="add" id="add" class="btn btn-info" data-toggle="modal" data-target="#add_product">ADD</button>
22                 <button type=
"button" class="btn btn-info" onclick="categories()"><i class="fa fa-plus"></i>Categories</button>
23             </div>
24             <div
class="col-md-6">
25                 <form
class="form-inline pull-right">
26                   <div
class="form-group">
27                     <label
class="sr-only" for="search">Search for</label>
28                     <div
class="input-group">
29                       <div
class="input-group-addon"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>
30                       <input type=
"text" class="form-control" id="search" placeholder="Type a name">
31                       <div
class="input-group-addon"></div>
32                     </div>
33                   </div>
34                   <!-- <button type=
"submit" class="btn btn-info">Search</button> -->
35                 </form>
36             </div>
37         </div>
38         <table id=
"product_data" class="table table-striped">
39             <thead
class="thead">
40               <tr
class="info">
41                 <th>ID</th>
42                 <th>Action</th>
43                 <th>Name</th>
44                 <th>Details</th>
45                 <th>Category</th>
46                 <th>Unit</th>
47               </tr>
48             </thead>
49           <tbody>
50           </tbody>
51         </table>
52     </div>
53     </div>
54     </div>
55     <!-- invisible content -->
56     <!-- New modal -->
57     <div
class="modal fade" id="add_product">
58         <div
class="modal-dialog" role="document">
59           <div
class="modal-content">
60                 <div
class="modal-header">
61                     <button type=
"button" class="close" data-dismiss="modal">×</button>
62                     <h4>Product Information</h4>
63                 </div>
64                 <form id=
"insert_form" method="POST">
65                     <div
class="modal-body">
66                         <!-- The
async form to send and replace the modals content with its response -->
67                             <fieldset>
68                                 <!-- form content -->
69                                     <div
class="form-group has-success">
70                                         <label
for="name">Name</label>
71                                         <input type=
"text" class="form-control" id="name" name="name" aria-describedby="emailHelp" placeholder="Enter Name" value="" required>
72                                         <!-- <small id=
"emailHelp" class="form-text text-muted">We'll never share your username with anyone else.</small> -->
73                                     </div>
74                                     <div
class="form-group">
75                                         <label
for="details">Details</label>
76                                         <input type=
"text" class="form-control" id="details" name="details" placeholder="Details" value="" required>
77                                     </div>
78                                     <div
class="form-group">
79                                             <label
for="category">Select Category</label>
80                                             <
select class="form-control form-control-sm" name="category" id="category">
81                                                 <?php
82                                                 require_once
"includes/classes/admin-class.php";
83                                                 $admins =
new Admins($dbh);
84                                                 $categories = $admins->fetchCategory();
85                                                 
if (isset($categories) && sizeof($categories) > 0){
86                                                     
foreach ($categories as $category) { ?>
87                                                     <option
value='<?=$category->cat_name?>'><?=$category->cat_name?></option>
88                                                 <?php }} ?>
89                                             </
select>
90                                     </div>
91                                     <div
class="form-group">
92                                         <label
for="unit">Unit</label>
93                                         <input type=
"text" class="form-control" id="unit" name="unit" placeholder="Unit" value="" required>
94                                     </div>
95                             </fieldset>
96                     </div>
97                     <div
class="modal-footer">
98                         <button type=
"submit" class="btn btn-primary">Submit</button>
99                         <a href=
"#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
100                     </div>
101                 </form>
102           </div>
103         </div>
104     </div>
105     <!-- modalend -->
106     <?php
107     include
'includes/footer.php';
108     ?>
109     <script type=
"text/javascript">
110
111         $(
'#insert_form').on('submit',function(event){
112             
event.preventDefault();
113             $.ajax({
114                 url:
"product_approve.php?p=add",
115                 method:
"POST",
116                 data:$(
'#insert_form').serialize(),
117                 success: function (data) {
118                     $(
'#insert_form')[0].reset();
119                     $(
'#add_product').modal('hide');
120                         viewData();
121                 }
122             });
123         });
124         function viewData() {
125             $.ajax({
126                 method:
"GET",
127                 url:
"product_approve.php",
128                 success: function(data){
129                     $(
'tbody').html(data);
130                 }
131             });
132         }
133         function delData(del_id){
134             
var id = del_id;
135             $.ajax({
136                 method:
"POST",
137                 url:
"product_approve.php?p=del",
138                 data:
"id="+id,
139                 success: function (data){
140                     viewData();
141                 }
142             });
143         }
144         function upData(str){
145             
var name = $('#nm-'+str).val();
146             
var unit = $('#un-'+str).val();
147             
var details = $('#dt-'+str).val();
148             
var color = $('#cl'+str).val();
149             
var length = $('#ln'+str).val();
150             
var radious = $('#rd'+str).val();
151             
var max = $('$mx'+str).val();
152             
var min = $('$mn'+str).val();
153             
var id = str;
154             $.ajax({
155                 method:
"POST",
156                 url:
"product_approve.php?p=edit",
157                 data:
"name="+name+"&unit="+unit+"&details="+details+"&color="+color+"&length="+length+"&radious="+radious+"&max="+max+"&min="+min+"&id="+id,
158                 success: function (data){
159                     viewData();
160                 }
161             });
162         }
163         window.onload=viewData();
164     </script>
165
166     <script type=
"text/javascript">
167       $(function() {
168         grid = $(
'#product_data');
169
170         
// handle search fields of members key up event
171         $(
'#search').keyup(function(e) {
172           text = $(
this).val(); // grab search term
173
174           
if(text.length > 1) {
175             grid.find(
'tr:has(td)').hide(); // hide data rows, leave header row showing
176
177             
// iterate through all grid rows
178             grid.find(
'tr').each(function(i) {
179               
// check to see if search term matches Name column
180               
if($(this).find('.search').text().toUpperCase().match(text.toUpperCase()))
181                 $(
this).show(); // show matching row
182             });
183           }
184           
else
185             grid.find(
'tr').show(); // if no matching name is found, show all rows
186         });
187         
188       });
189         function categories() {
190         
let left = (screen.width/2)-(600/2);
191     
let top = (screen.height/2)-(800/2);
192         
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=600,height=800,left=${left},top=${top}`;
193         open(
'categories.php', 'Categories', params)
194         }
195     </script>


Gõ tìm kiếm nhanh...